/*
 * File:                AbstractStandardController.cs
 * Authors:             
 * Company:             Sandia National Laboratories
 * Project:             MVC
 *
 * Copyright 2008, Sandia Corporation.  Under the terms of Contract
 * DE-AC04-94AL85000, there is a non-exclusive license for use of this work by
 * or on behalf of the U.S. Government. Export of this program may require a
 * license from the United States Government. See CopyrightHistory.txt for
 * complete details.
 *
 * Reviewers:
 * Review Date:
 * Review Comments:
 *
 * Revision History:
 *
 * $Log: AbstractStandardController.cs,v $
 * Revision 1.18  2008/10/28 14:41:22  bstitus
 * Added the collections for the importers and exporters to AbstractStandardController.  A prior bug moved most of the other collections to this class.  Moved the instantiation of the collections (new and previously moved) to a new constructor in this class.  Bug #1254
 *
 * Revision 1.17  2008/10/24 19:31:05  bstitus
 * Converted the dictionary data types to Lists and updated the code because of the different methods for List.  Bug # 1256
 *
 * Revision 1.16  2008/10/23 22:11:19  bstitus
 * Forgot the keyword, abstract.  Bug #1258
 *
 * Revision 1.15  2008/10/23 21:06:26  bstitus
 * Created a new class that inherits from StandardPublisher and implements the IStartable interface.  Bug #1258
 *
 *
 *
 */


using Sandia.MVCFramework.Common;
using Sandia.MVCFramework.DataAccessor;
using Sandia.MVCFramework.DataAnalyzer;
using Sandia.MVCFramework.DataStore;
using Sandia.MVCFramework.ExportTools;
using Sandia.MVCFramework.ViewManager;

using System;
using System.Collections.Generic;
using System.Text;

namespace Sandia.MVCFramework.Controller
{
    /// <summary>
    /// 
    /// </summary>
    public abstract class AbstractStandardController : StandardPublisher, IStartable
    {
        /// <summary>
        /// The collection of IDataAccessors for the application
        /// 'bool' is not used
        /// </summary>
        protected List<IDataAccessor> dataAccessors;

        /// <summary>
        /// The collection of IDataAnalyzers for the application
        /// 'bool' is not used
        /// </summary>
        protected List<IDataAnalyzer> dataAnalyzers;

        /// <summary>
        /// The collection of IDataStores for the application
        /// 'bool' is not used
        /// </summary>
        protected List<IDataStore> dataStores;

        /// <summary>
        /// The collection of IViewManagers for the application
        /// 'bool' is not used
        /// </summary>
        protected List<IViewManager> viewManagers;

        /// <summary>
        /// The collection of IImporters for the application
        /// </summary>
        protected List<IImporter> importers;

        /// <summary>
        /// The collection of IExporters for the application
        /// </summary>
        protected List<IExporter> exporters;

        /// <summary>
        /// Initialize the class
        /// </summary>
        protected AbstractStandardController()
        {
            this.dataAccessors = new List<IDataAccessor>();
            this.dataAnalyzers = new List<IDataAnalyzer>();
            this.dataStores = new List<IDataStore>();

            this.viewManagers = new List<IViewManager>();

            this.importers = new List<IImporter>();
            this.exporters = new List<IExporter>();
        }


        #region IStartable Members

        /// <summary>
        /// Called when MVC Framework initialization has completed and
        /// transactions can begin.
        /// </summary>
        /// <remarks>
        /// StandardController uses this method to inform its internal 
        /// components that it is OK to begin transactions.
        /// 
        /// IRequests and IData should not be sent before this method is called, 
        /// as this can cause race conditions while an application is 
        /// initializing.
        /// </remarks>
        public void Start()
        {
            foreach (IDataAccessor dataAccessor in this.dataAccessors)
            {
                dataAccessor.Start();
            }

            foreach (IDataAnalyzer dataAnalyzer in this.dataAnalyzers)
            {
                dataAnalyzer.Start();
            }

            foreach (IDataStore dataStore in this.dataStores)
            {
                dataStore.Start();
            }

            foreach (IViewManager viewManager in this.viewManagers)
            {
                viewManager.Start();
            }
        }

        #endregion
    }
}
